package top.juntower.utils;

import org.apache.commons.codec.digest.DigestUtils;

public class Md5Salt {

    //生成MD5密码串
    public static   String  md5(String keyword){
        String s=md5PlusSalt(DigestUtils.md5Hex(keyword));
        return s;
    }



    //加盐
    public static String md5PlusSalt(String keyword)
    {
        String md5= DigestUtils.md5Hex(keyword);
        char[]cArray=md5.toCharArray();
        for(int i=0;i<cArray.length;i++)
        {
            if(cArray[i]>=48&&cArray[i]<=57)
            {
                cArray[i]=(char)(105-cArray[i]);

            }
        }
        return  "".valueOf(cArray);

    }


    //解密
    public static String md5MinusSalt(String md5)
    {
        char[]cArray=md5.toCharArray();
        for(int i=0;i<cArray.length;i++)
        {
            if(cArray[i]>=48&&cArray[i]<=57)
            {
                cArray[i]=(char)(105-cArray[i]);

            }
        }
        return  "".valueOf(cArray);

    }
}
